#ifndef __UTIL_H
#define __UTIL_H

#include <wx/string.h>
#include <wx/msgdlg.h>
#include <wx/textctrl.h>
#include "debug.h"


inline void WarnMsg_internal(const wxString& text)
    {dbg("WarnMsg(\"%s\")\n", text.wx_str()); wxMessageBox(text, _("Warning"), wxICON_WARNING | wxOK);}
#if defined(__GNUC__)
    #define WarnMsg(x, args...) do {WarnMsg_internal(wxString::Format(x, ## args));} while(0)
#elif defined(_MSC_VER)
    #define WarnMsg(x, ...) do {WarnMsg_internal(wxString::Format(x, __VA_ARGS__));} while(0)
#endif

inline void ErrMsg_internal(const wxString& text)
    {dbg("ErrMsg(\"%s\")\n", text.wx_str()); wxMessageBox(text, _("Error"), wxICON_ERROR | wxOK);}
#if defined(__GNUC__)
    #define ErrMsg(x, args...) do {ErrMsg_internal(wxString::Format(x, ## args));} while(0)
#elif defined(_MSC_VER)
    #define ErrMsg(x, ...) do {ErrMsg_internal(wxString::Format(x, __VA_ARGS__));} while(0)
#endif

inline bool Confirm(const wxString& text, const wxString& caption=_("Confirm"))
    {return (wxYES == wxMessageBox(text, caption, wxYES_NO | wxNO_DEFAULT));}

bool InputString(wxString *result, const wxString& text=_("Input: "), const wxString& caption=_("Input string"));

#if defined(__GNUC__)
    #define wxFormat(x, args...) wxString::Format((x), ## args)
#elif defined(_MSC_VER)
    #define wxFormat(x, ...) wxString::Format((x), __VA_ARGS__)
#endif

int wxFont_GetHeight(const wxFont& font);

#ifdef TARGET_LINUX
int gtk_wxTextCtrl_GetWrappedHeight(wxTextCtrl *ctrl);
#endif

#ifdef TARGET_WIN32
int msw_wxTextCtrl_GetWrappedHeight(wxTextCtrl *ctrl, int wrapwidth);
#endif

#endif
